/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-05 14:56:52
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-05 14:58:02
 * @Description: file content
 */

#include "apue.h"

int main()
{
    pid_t pid;

    if ((pid = fork()) < 0)
    {
        err_sys("fork error");
    }
    else if (0 != pid)
    {
        sleep(2);
        exit(2);
    }

    if ((pid = fork()) < 0)
    {
        err_sys("fork error");
    }
    else if (0 != pid)
    {
        sleep(4);
        abort();
    }

    if ((pid = fork()) < 0)
    {
        err_sys("fork error");
    }
    else if (0 != pid)
    {
        execl("/bin/dd", "dd", "if=/etc/passwd", "of=/dev/null", NULL);
        exit(7);
    }

    if ((pid = fork()) < 0)
    {
        err_sys("fork error");
    }
    else if (0 != pid)
    {
        sleep(8);
        exit(0);
    }

    sleep(6);
    kill(getpid(), SIGKILL);
    exit(6);
}
